<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * @var $block \Magento\Backend\Block\Widget\Grid\Serializer
 */
?>
<?php $_id = 'id_' . md5(microtime()) ?>
<?php $formId = $block->getFormId()?>
<?php if (!empty($formId)) :?>
<script>
    require([
        'prototype',
        'mage/adminhtml/grid'
    ], function(){
        Event.observe(window, "load", function(){
            var serializeInput  = document.createElement('input');
            serializeInput.type = 'hidden';
            serializeInput.name = '<?php /* @escapeNotVerified */ echo $block->getInputElementName()?>';
            serializeInput.id   = '<?php /* @escapeNotVerified */ echo $_id?>';
            try {
                document.getElementById('<?php /* @escapeNotVerified */ echo $formId?>').appendChild(serializeInput);
                new serializerController('<?php /* @escapeNotVerified */ echo $_id?>', <?php /* @escapeNotVerified */ echo $block->getDataAsJSON() ?>, <?php /* @escapeNotVerified */ echo $block->getColumnInputNames(true) ?>, <?php /* @escapeNotVerified */ echo $block->getGridBlock()->getJsObjectName() ?>, '<?php /* @escapeNotVerified */ echo $block->getReloadParamName()?>');
            } catch(e) {
                //Error add serializer
            }
        });
    });
</script>
<?php else :?>
<input type="hidden" name="<?php /* @escapeNotVerified */ echo $block->getInputElementName()?>"  value="" id="<?php /* @escapeNotVerified */ echo $_id?>" />
<script>
    require([
        'mage/adminhtml/grid'
    ], function(){
        new serializerController('<?php /* @escapeNotVerified */ echo $_id?>', <?php /* @escapeNotVerified */ echo $block->getDataAsJSON() ?>, <?php /* @escapeNotVerified */ echo $block->getColumnInputNames(true) ?>, <?php /* @escapeNotVerified */ echo $block->getGridBlock()->getJsObjectName() ?>, '<?php /* @escapeNotVerified */ echo $block->getReloadParamName()?>');
    });
</script>
<?php endif;?>
